<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户注册</title>
    <style>
        body { font-family: Arial, sans-serif; display: flex; flex-direction: column; align-items: center; padding-top: 50px; }
        .register-box { width: 300px; border: 1px solid #eee; padding: 20px; }
        .form-group { margin-bottom: 15px; }
        label { display: block; margin-bottom: 5px; }
        input { width: 100%; padding: 8px; box-sizing: border-box; }
        button { width: 100%; padding: 10px; background: #4CAF50; color: white; border: none; cursor: pointer; }
        button:hover { background: #45a049; }
        .link { margin-top: 15px; text-align: center; }
        a { color: #0066cc; }
    </style>
</head>
<body>
    <h2>用户注册</h2>
    <div class="register-box">
        <form id="registerForm">
            <div class="form-group">
                <label for="regUsername">用户名</label>
                <input type="text" id="regUsername" required>
            </div>
            <div class="form-group">
                <label for="regPhone">手机号</label>
                <input type="tel" id="regPhone" required>
            </div>
            <div class="form-group">
                <label for="regPassword">密码</label>
                <input type="password" id="regPassword" required>
            </div>
            <div class="form-group">
                <label for="regConfirm">确认密码</label>
                <input type="password" id="regConfirm" required>
            </div>
            <button type="button" onclick="register()">注册</button>
        </form>
        <div class="link">
            已有账号？<a href="login.html">立即登录</a>
        </div>
    </div>

    <script>
        function register() {
            const username = document.getElementById('regUsername').value;
            const phone = document.getElementById('regPhone').value;
            const password = document.getElementById('regPassword').value;
            const confirm = document.getElementById('regConfirm').value;

            if (!username || !phone || !password || !confirm) {
                alert('请填写完整信息');
                return;
            }

            if (password !== confirm) {
                alert('两次密码不一致');
                return;
            }

            // 实际项目中会发送注册请求到服务器
            alert('注册成功，请登录');
            window.location.href = 'login.html';
        }
    </script>
</body>
</html>